package edu.ustb.efws;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;


/**
 * 系统配置属性
 *
 * @author TS Group
 */
@ConfigurationProperties(prefix = "efws")
public class EfwsProperties {

    /**
     * 是否创建表
     */
    private boolean createTable = false;

    /**
     * 数据开始月份
     */
    private int startMonth = -1;

    /**
     * 最大采集条数
     */
    private int collectLimit = 50;

    /**
     * 采集工作线程数
     */
    private int collectWorks = 4;

    /**
     * 采集时间间隔
     */
    private long collectPeriodMills = 1000;

    /**
     * 测试指标时间窗设置
     */
    private int windowTimeMin = 5;

    /**
     * 测量每天开始时间（分）
     */
    private int meterStartMinute = 9 * 60;

    /**
     * 测量每天结束时间（分）
     */
    private int meterEndMinute = 16 * 60;

    /**
     * 关闭等待时间
     */
    private int waitShutdownSec = 120;

    /**
     * 是否启动数据采集
     */
    private boolean enableCollect = false;

    /**
     * 短信账户
     */
    private String smsAccount = "13956102941";

    /**
     * 短信key
     */
    private String smsKey = "23db992d9aaf45bfa7b246b7ddf20dd2";

    /**
     * 短信发送API URL
     */
    private String smsUrl = "http://api.yunzhixin.com:11140/txp/sms/send";

    /**
     * 短信发送模板
     */
    private String smsTemplate = "TP20061118";

    /**
     * 短信发送报警时间间隔
     */
    private int smsWarIntervalSecs = 1800;

    /**
     * 短信发送报警分数
     */
    private int smsWarScore = 60;

    /**
     * 保存最小日志数据月
     */
    private int minLogDataMonth = 3;

    /**
     * 临时目录
     */
    private String tmpPath="/tmp";

    public boolean isCreateTable() {
        return createTable;
    }

    public void setCreateTable(boolean createTable) {
        this.createTable = createTable;
    }

    public int getStartMonth() {
        return startMonth;
    }

    public void setStartMonth(int startMonth) {
        this.startMonth = startMonth;
    }

    public int getCollectLimit() {
        return collectLimit;
    }

    public void setCollectLimit(int collectLimit) {
        this.collectLimit = collectLimit;
    }

    public int getCollectWorks() {
        return collectWorks;
    }

    public void setCollectWorks(int collectWorks) {
        this.collectWorks = Math.min(100, collectWorks);
    }

    public long getCollectPeriodMills() {
        return collectPeriodMills;
    }

    public void setCollectPeriodMills(long collectPeriodMills) {
        this.collectPeriodMills = collectPeriodMills;
    }

    public int getWindowTimeMin() {
        return windowTimeMin;
    }

    public void setWindowTimeMin(int windowTimeMin) {
        this.windowTimeMin = windowTimeMin;
    }

    public int getMeterStartMinute() {
        return meterStartMinute;
    }

    public void setMeterStartMinute(int meterStartMinute) {
        this.meterStartMinute = meterStartMinute;
    }

    public int getMeterEndMinute() {
        return meterEndMinute;
    }

    public void setMeterEndMinute(int meterEndMinute) {
        this.meterEndMinute = meterEndMinute;
    }

    public int getWaitShutdownSec() {
        return waitShutdownSec;
    }

    public void setWaitShutdownSec(int waitShutdownSec) {
        this.waitShutdownSec = waitShutdownSec;
    }

    public boolean isEnableCollect() {
        return enableCollect;
    }

    public void setEnableCollect(boolean enableCollect) {
        this.enableCollect = enableCollect;
    }

    public String getSmsAccount() {
        return smsAccount;
    }

    public void setSmsAccount(String smsAccount) {
        this.smsAccount = smsAccount;
    }

    public String getSmsKey() {
        return smsKey;
    }

    public void setSmsKey(String smsKey) {
        this.smsKey = smsKey;
    }

    public String getSmsUrl() {
        return smsUrl;
    }

    public void setSmsUrl(String smsUrl) {
        this.smsUrl = smsUrl;
    }

    public String getSmsTemplate() {
        return smsTemplate;
    }

    public void setSmsTemplate(String smsTemplate) {
        this.smsTemplate = smsTemplate;
    }

    public int getSmsWarIntervalSecs() {
        return smsWarIntervalSecs;
    }

    public void setSmsWarIntervalSecs(int smsWarIntervalSecs) {
        this.smsWarIntervalSecs = smsWarIntervalSecs;
    }

    public int getSmsWarScore() {
        return smsWarScore;
    }

    public void setSmsWarScore(int smsWarScore) {
        this.smsWarScore = smsWarScore;
    }

    public int getMinLogDataMonth() {
        return minLogDataMonth;
    }

    public void setMinLogDataMonth(int minLogDataMonth) {
        this.minLogDataMonth = minLogDataMonth;
    }

    public String getTmpPath() {
        return tmpPath;
    }

    public void setTmpPath(String tmpPath) {
        this.tmpPath = tmpPath;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("createTable", createTable)
                .append("startMonth", startMonth)
                .append("collectLimit", collectLimit)
                .append("collectWorks", collectWorks)
                .append("collectPeriodMills", collectPeriodMills)
                .append("windowTimeMin", windowTimeMin)
                .append("meterStartMinute", meterStartMinute)
                .append("meterEndMinute", meterEndMinute)
                .append("waitShutdownSec", waitShutdownSec)
                .append("enableCollect", enableCollect)
                .append("smsAccount", smsAccount)
                .append("smsKey", smsKey)
                .append("smsUrl", smsUrl)
                .append("smsTemplate", smsTemplate)
                .append("smsWarIntervalSecs", smsWarIntervalSecs)
                .append("smsWarScore", smsWarScore)
                .append("minLogDataMonth", minLogDataMonth)
                .append("tmpPath", tmpPath)
                .toString();
    }
}
